//
//  ViewController.m
//  01 -- 创建UIViewByCode
//
//  Created by Rainy Zou on 15/11/16.
//  Copyright © 2015年 Rainy Zou. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController


#pragma mark 当view 加载完成，将触发该事件
- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    // 1 创建按钮
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    // 1.1 设置button在常规下的文本
    [btn setTitle:@"点我呀！" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    
    //1.2 设置button在高亮下的文本
    [btn setTitle:@"放开我，流氓！" forState:UIControlStateHighlighted];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
    
    btn.frame = CGRectMake(0, 0, 200, 100);
    
    [self.view addSubview:btn];
    
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void) btnClick:(id) sender
{
    NSLog(@"点击了按钮！");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
